//
//  MessageViewModel.swift
//  mmda
//
//  Created by 李陆涛 on 2018/8/13.
//  Copyright © 2018年 mmda. All rights reserved.
//

import UIKit

class MessageViewModel: NSObject {

    var dataSource:[Message]?
    
    var loadFinished: ((_ error: String?) -> Void)?
    
    
    func loadData() {
        
        NetAPI.notice.request([Message].self) {
            
            [weak self] response, errmsg in
            guard let `self` = self else { return }
            
            guard let array = response as? [Message] else {
                
                self.loadFinished?(errmsg)
                return
            }
            
            self.dataSource = array
            
            self.loadFinished?(nil)
            
        }
    }
    
}
